home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr52 / ncclib.zip / NCCDEMO.ZIP / G_WIN.PRG < prev    next >
Text File  |  1992-11-03  |  21KB  |  816 lines

  1. //═══════════════════════════════════════════════════════╕
  2. //  Program .....: G_Window                              │
  3. //  CopyRight ...: 1992 National Computer Consultants    │
  4. //                 All rights are reserved.              │
  5. //  Author ......: Greg Rice                             │
  6. //═══════════════════════════════════════════════════════╛
  7.  
  8. //─────────────┐
  9. //  Desktop    │
  10. //─────────────┘
  11.  
  12. #include "inkey.ch"
  13. #include "dbstruct.ch"
  14. #include "g_menu.ch"
  15. #include "mouse.ch"
  16.  
  17.  
  18.  
  19. #define WINDOW_INDEXFILES     1
  20. #define WINDOW_ALIAS          2
  21. #define   WINDOW_FILENAME       1
  22. #define   WINDOW_OBJECT         2
  23. #define   WINDOW_COLOR          3
  24. #define   WINDOW_TROW           4
  25. #define   WINDOW_LCOL           5
  26. #define   WINDOW_BROW           6
  27. #define   WINDOW_RCOL           7
  28. #define WINDOW_VIEWFIELDS     3
  29. #define WINDOW_VIEWSTRUCT     4
  30.  
  31. STATIC window_active  := .f.
  32.  
  33. STATIC title_Color    := 'W+/B'                                             , ;
  34.        message_Color  := 'W+/R'                                           , ;
  35.        desktop_Color  := 'W+/N*'                                           , ;
  36.        desktop_char   := "▒"                                               , ;
  37.        popup_color    := 'W+/RB,W+/B,,W+/RB'                             , ;
  38.        bar_color      := 'R/BG,W+/R,,W+/BG,W+/R'                          , ;
  39.                                                                              ;
  40.        SaveMode       := NIL                                               , ;
  41.                                                                              ;
  42.        Current_window := 1                                                 , ;
  43.        win_Stack := {}          // Window sequence
  44.  
  45.  
  46. /*                      W I N D O W   S T R U C T U R E
  47.   ***************************************************************************
  48.  
  49.  
  50.   Viewing File Structure  ───────────────────────────────────────────────┐
  51.   Viewing Field List     ──────────────────────────────────────────┐     │
  52.   RightColumn           ─────────────────────────────────────┐     │     │
  53.   BottomRow            ───────────────────────────────────┐  │     │     │
  54.   LeftColumn          ─────────────────────────────────┐  │  │     │     │
  55.   TopRow             ───────────────────────────────┐  │  │  │     │     │
  56.   Window Color      ────────────┐                   │  │  │  │     │     │
  57.   Assoc. object    ─────────┐   │                   │  │  │  │     │     │
  58.   Full File name  ───────┐  │   │                   │  │  │  │     │     │
  59.   Index Array    ──┐     │  │   │                   │  │  │  │     │     │
  60.                    │     │  │   │                   │  │  │  │     │     │
  61.                    v     v  v   v                   v  v  v  v     v     v
  62.  
  63.   ***************************************************************************
  64. */
  65. STATIC win := {;
  66.                 { {""}, {'','','W+/B,GR+/RB,,,W+/B'   ,04,02,20,75}, {""}, NIL } ,;
  67.                 { {""}, {'','','N/W,W+/R,,,N/W'       ,03,01,16,72}, {""}, NIL } ,;
  68.                 { {""}, {'','','N/BG,W+/R,,,W+/B'     ,04,02,17,73}, {""}, NIL } ,;
  69.                 { {""}, {'','','N/GR,W+/RB,,,N/BR'    ,05,03,18,74}, {""}, NIL } ,;
  70.                 { {""}, {'','','N/G,R+/RB,,,N/W'      ,06,04,19,75}, {""}, NIL } ,;
  71.                 { {""}, {'','','G+/B,W+/R,,,W+/B'     ,07,05,20,76}, {""}, NIL } ,;
  72.                 { {""}, {'','','GR/W,GR+/RB,,,N/W'    ,08,06,21,77}, {""}, NIL } ,;
  73.                 { {""}, {'','','GR+/B,W+/R,,,W+/B'    ,09,07,22,78}, {""}, NIL } ,;
  74.                 { {""}, {'','','R/W,GR+/RB,,,N/W'     ,10,08,23,79}, {""}, NIL }  ;
  75.               }
  76.  
  77.  
  78. //
  79. //────────────────────────────────────────────────────────────────────────────
  80. //
  81.  
  82. Function Window_Active(x)
  83. Return( if( x == NIL, window_active, window_active := x ) )
  84.  
  85. Func Win_Stack( x )
  86. Return(;
  87.         if( x == NIL, ;
  88.             win_stack, ;
  89.             win_Stack := x ;
  90.           );
  91.       )
  92.  
  93. Func winStackUpdate( x )
  94.  
  95.    local i
  96.  
  97.    if (i := ascan( win_stack, x )) # 0
  98.      adel( win_stack, i )
  99.      win_stack[len(win_stack)] := x
  100.    else
  101.      aadd( win_stack, x )
  102.    endif
  103.  
  104. Return( NIL )
  105.  
  106.  
  107. Func Windows()
  108. Return( win )
  109.  
  110. Func Title_Color( x )
  111. Return( if( x == NIL, Title_Color, Title_Color := x ) )
  112.  
  113. Func Message_Color( x )
  114. Return( if( x == NIL, Message_Color, Message_Color := x ) )
  115.  
  116. Func DeskTop_Color( x )
  117. Return( if( x == NIL, DeskTop_Color, DeskTop_Color := x ) )
  118.  
  119. Func DeskTop_Char( x )
  120. Return( if( x == NIL, DeskTop_Char, DeskTop_Char := x ) )
  121.  
  122. Func Popup_Color( x )
  123. Return( if( x == NIL, Popup_Color, Popup_Color := x ) )
  124.  
  125. Func Bar_Color( x )
  126. Return( if( x == NIL, Bar_Color, Bar_Color := x ) )
  127.  
  128. Func Current_Window( x )
  129. Return( if( x == NIL, Current_Window, Current_Window := x ) )
  130.  
  131.  
  132. Func SaveMode( x )
  133. Return( if( x == NIL, SaveMode, SaveMode := x ) )
  134.  
  135.  
  136. Func WinIndexFiles( x, y )
  137.     x := if( x == NIL, current_window, x )
  138. Return( ;
  139.         if( y == NIL, ;
  140.             y := Win[x,WINDOW_INDEXFILES], ;
  141.             Win[x,WINDOW_INDEXFILES] := y ;
  142.           );
  143.        )
  144.  
  145. Func WinFilename( x, y )
  146.  x := if( x == NIL, current_window, x )
  147. Return(;
  148.         if( y == NIL, ;
  149.             y := Win[x,2,WINDOW_FILENAME], ;
  150.             Win[x,2,WINDOW_FILENAME] := y ;
  151.           );
  152.       )
  153.  
  154. Func WinObj( x, y )
  155.  x := if( x == NIL, Current_Window, x )
  156. Return(;
  157.         if( y == NIL, ;
  158.             y := Win[x,2,WINDOW_OBJECT], ;
  159.             Win[x,2,WINDOW_OBJECT] := y ;
  160.           );
  161.       )
  162.  
  163. Func WinColor( x, y )
  164.  x := if( x == NIL, current_window, x )
  165. Return(;
  166.         if( y == NIL, ;
  167.             y := Win[x,2,WINDOW_COLOR], ;
  168.             Win[x,2,WINDOW_COLOR] := y ;
  169.           );
  170.       )
  171.  
  172. Func WinTop( x, y )
  173.  x := if( x == NIL, current_window, x )
  174. Return(;
  175.         if( y == NIL, ;
  176.             y := Win[x,2,WINDOW_TROW], ;
  177.             Win[x,2,WINDOW_TROW] := y ;
  178.           );
  179.       )
  180.  
  181. Func WinLeft( x, y )
  182.  x := if( x == NIL, current_window, x )
  183. Return(;
  184.         if( y == NIL, ;
  185.             y := Win[x,2,WINDOW_LCOL], ;
  186.             Win[x,2,WINDOW_LCOL] := y ;
  187.           );
  188.       )
  189.  
  190. Func WinBottom( x, y )
  191.  x := if( x == NIL, current_window, x )
  192. Return(;
  193.         if( y == NIL, ;
  194.             y := Win[x,2,WINDOW_BROW], ;
  195.             Win[x,2,WINDOW_BROW] := y ;
  196.           );
  197.       )
  198.  
  199. Func WinRight( x, y )
  200.  x := if( x == NIL, current_window, x )
  201. Return(;
  202.         if( y == NIL, ;
  203.             y := Win[x,2,WINDOW_RCOL], ;
  204.             Win[x,2,WINDOW_RCOL] := y ;
  205.           );
  206.       )
  207.  
  208. Func WinViewFields( x, y )
  209.  x := if( x == NIL, current_window, x )
  210. Return(;
  211.         if( y == NIL, ;
  212.             y := Win[x,WINDOW_VIEWFIELDS], ;
  213.             Win[x,WINDOW_VIEWFIELDS] := y ;
  214.           );
  215.       )
  216.  
  217. Func WinViewStru( x, y )
  218.  x := if( x == NIL, current_window, x )
  219. Return(;
  220.         if( y == NIL, ;
  221.             y := Win[x,WINDOW_VIEWSTRUCT], ;
  222.             Win[x,WINDOW_VIEWSTRUCT] := y ;
  223.           );
  224.       )
  225.  
  226. FUNCTION ColorSetup(x)
  227.  
  228.     local i
  229.  
  230.     if '/M' $ uppe(x) .or. ! isColor()
  231.        Title_color   := 'N/W'
  232.        desktop_color := 'N/N,N/W'
  233.        popup_color   := 'N/W,W+/N,,,N/W'
  234.        bar_color     := 'N/W,W/N,,N+/W,W+/N'
  235.        message_color := 'W+/N'
  236.  
  237.        for i = 1 to 9
  238.          WinColor(i,'W/N,N/W,,,W/N')
  239.        next
  240.  
  241.     endif
  242.  
  243. Return( NIL )
  244.  
  245.  
  246. //───────────────┐
  247. //  Next Window  │
  248. //───────────────┘
  249. Function WinNext()
  250.  
  251.     local nKey, i
  252.  
  253.     nKey := Current_Window()
  254.     DeHighLightWindow(nKey)
  255.     for i = 1 to len(windows())
  256.       nKey++
  257.       if nKey > Len(windows())
  258.         nKey := 1
  259.       endif
  260.       if ! Empty(WinFilename(nKey))
  261.         exit
  262.       endif
  263.     next
  264.     HighLightWindow( nKey )
  265.  
  266. Return( NIL )
  267.  
  268.  
  269. //─────────────────┐
  270. // Previous Window │
  271. //─────────────────┘
  272. Function WinPrev()
  273.  
  274.     local nKey, i
  275.  
  276.     nKey := Current_Window()
  277.     DeHighLightWindow(nKey)
  278.     for i = 1 to len(windows())
  279.       nKey--
  280.       if nKey == 0
  281.         nKey := len(windows())
  282.       endif
  283.       if ! Empty(WinFilename(nKey))
  284.         exit
  285.       endif
  286.     next
  287.     HighLightWindow( nKey )
  288.  
  289. Return( NIL )
  290.  
  291. //───────────────┐
  292. // Resize Window │
  293. //───────────────┘
  294. Function WinResize()
  295.  
  296.     ResizeWindow( WinObj() )
  297.     ShowDesktop()
  298.  
  299. Return( NIL )
  300.  
  301.  
  302.  
  303. Function ZoomIsFull()
  304.  
  305.     local zoom := .f., o := WinObj()
  306.  
  307.  
  308.     if Window_Active()
  309.       if ! ( o:TopRow-4      == WinTop() .and.       ;
  310.              o:LeftColumn-1  == WinLeft() .and.      ;
  311.              o:BottomRow+1   == WinBottom() .and.    ;
  312.              o:RightColumn+1 == WinRight()           ;
  313.            )
  314.          zoom := .t.
  315.       endif
  316.     endif
  317.  
  318. Return( zoom )
  319.  
  320. //───────────────┐
  321. //  Zoom Window  │
  322. //───────────────┘
  323. Function WinZoom()
  324.  
  325.     local o := WinObj()
  326.  
  327.     if ! ZoomIsFull()
  328.       o:TopRow       := 6
  329.       o:LeftColumn   := 1
  330.       o:BottomRow    := maxrow() -2
  331.       o:RightColumn  := maxcol() -1
  332.       HighLightWindow()
  333.  
  334.     else
  335.       o:TopRow       := WinTop()+4
  336.       o:LeftColumn   := WinLeft()+1
  337.       o:BottomRow    := WinBottom()-1
  338.       o:RightColumn  := WinRight()-1
  339.       ShowDeskTop()
  340.  
  341.     endif
  342.  
  343. Return( NIL )
  344.  
  345.  
  346. //───────────────────┐
  347. // Highlight Window  │
  348. //───────────────────┘
  349. Function HighlightWindow( x )
  350.  
  351.     x := if( x == NIL, current_window, x )
  352.     Sele ( x )
  353.     winStackUpdate( x )
  354.     Current_Window( x )
  355.     WindowFrame(WinObj( x ))
  356.     WinObj( x ):RefreshAll()
  357.  
  358. Return( NIL )
  359.  
  360.  
  361. //──────────────────────┐
  362. // De Highlight Window  │
  363. //──────────────────────┘
  364. Function DeHighlightWindow( x )
  365.  
  366.     local TopRow, ;
  367.           LeftColumn, ;
  368.           BottomRow, ;
  369.           RightColumn, ;
  370.           StandardColor, ;
  371.           Window
  372.  
  373.  
  374.     x := if( x == NIL, current_window, x )
  375.     if empty(alias(x))
  376.       Return( NIL )
  377.     endif
  378.  
  379.     Window := WinObj(x)
  380.  
  381.     TopRow        := Window:TopRow -4
  382.     LeftColumn    := Window:LeftColumn -1
  383.     BottomRow     := Window:BottomRow +1
  384.     RightColumn   := Window:RightColumn +1
  385.     StandardColor := Window:StandardColor
  386.  
  387.     Setcolor( StandardColor )
  388.     WinBox(TopRow,LeftColumn,BottomRow,RightColumn,0,'┌─┐│┘─└│', ;
  389.                if(BottomRow==maxrow()-1,.f.,.t.) ;
  390.             )
  391.  
  392.     @ TopRow, LeftColumn+1 say " " + eval( Window:UserSlot[1] ) + ;
  393.                                      "  < Window  " + ;
  394.                                      str(select(),1,0)+" > " ;
  395.                                color Window:InverseColor
  396.  
  397.  
  398.     Window:ShowStatus()
  399.  
  400. Return( NIL )
  401.  
  402.  
  403. //─────────────┐
  404. // Open Desktop│
  405. //─────────────┘
  406. Function OpenDesktop()
  407.  
  408.     local init, i, j
  409.  
  410.  
  411.     win_Stack( {} )
  412.     init := .t.
  413.     j := if(empty(alias()),1,select())
  414.     for i = 1 to len(Windows())
  415.       j++
  416.       if j > Len(windows())
  417.         j := 1
  418.       endif
  419.       if ! empty( alias(j) )
  420.         if ! init
  421.           DeHighLightWindow(Current_Window())
  422.         endif
  423.         OpenWindow(j)
  424.         init := .f.
  425.       endif
  426.     next
  427.  
  428. Return( NIL )
  429.  
  430.  
  431. //──────────────────┐
  432. // Display DeskTop  │
  433. //──────────────────┘
  434. Function ShowDeskTop()
  435.  
  436.     local i, j := Current_Window()
  437.  
  438.  
  439.     ShowBackGround()
  440.     for i = 1 to len(windows())
  441.       j++
  442.       if j > Len(windows())
  443.         j := 1
  444.       endif
  445.       Current_Window( j )
  446.       if ! empty(WinFilename(j))
  447.         HighLightWindow( j )
  448.         if i # len(windows())
  449.           DeHighLightWindow(j)
  450.         endif
  451.       endif
  452.     next
  453.  
  454. Return( NIL )
  455.  
  456. //───────────────┐
  457. // Open Window   │
  458. //───────────────┘
  459. Function OpenWindow(x)
  460.  
  461.     local o, y, Window := WinObj()
  462.  
  463.  
  464.     if x == NIL
  465.       x := Current_window()
  466.     endif
  467.  
  468.     if empty(alias(x))
  469.       Return( NIL )
  470.     endif
  471.  
  472.  
  473.     if ! empty( Window )
  474.       WinTop( , Window:TopRow -4 )
  475.       WinLeft( , Window:LeftColumn -1 )
  476.       WinBottom( , Window:BottomRow +1 )
  477.       WinRight( , Window:RightColumn +1 )
  478.     endif
  479.  
  480.     winStackUpdate( x )
  481.     Current_Window( x )
  482.     Sele (x)
  483.  
  484.  
  485.     Setcolor(WinColor())
  486.     o := dViewDBF():New( WinTop()    +4, ;
  487.                          WinLeft()   +1, ;
  488.                          WinBottom() -1, ;
  489.                          WinRight()  -1  ;
  490.                        )
  491.  
  492.     o:Head      := "═"
  493.     o:HeadSep   := "╤"
  494.     o:ColSep    := "│"
  495.     o:UserSlot  :=  {                                               ;
  496.                       { || FileBase(WinFilename(),".DBF") }       , ;
  497.                       NIL                                         , ;
  498.                       NIL                                           ;
  499.                     }
  500.     o:Structure :=  WinViewStru()
  501.     y           := {}
  502.     aeval( WinViewStru(), {|a| aadd(y, a[DBS_NAME]) } )
  503.     o:Headings  := y
  504.  
  505.     WindowFrame( o )
  506.     WinObj(x, o )
  507.  
  508.     WinObj():Activate()
  509.  
  510. Return( o )
  511.  
  512.  
  513. //───────────────────────┐
  514. // Display Window Frame  │
  515. //───────────────────────┘
  516. Function WindowFrame( x )
  517.  
  518.  
  519.     local TopRow        := x:TopRow -4, ;
  520.           LeftColumn    := x:LeftColumn -1, ;
  521.           BottomRow     := x:BottomRow +1, ;
  522.           RightColumn   := x:RightColumn +1, ;
  523.           StandardColor := x:StandardColor
  524.  
  525.  
  526.     Setcolor( StandardColor )
  527.  
  528.     if BottomRow > Maxrow() -1
  529.       TopRow := max( 2, maxrow() - (BottomRow - TopRow) )
  530.       BottomRow := Maxrow() -1
  531.     endif
  532.  
  533.     if RightColumn > Maxcol()
  534.       RightColumn := Maxcol()
  535.     endif
  536.  
  537.  
  538.     x:TopRow      := TopRow +4
  539.     x:LeftColumn  := LeftColumn +1
  540.     x:BottomRow   := BottomRow -1
  541.     x:RightColumn := RightColumn -1
  542.  
  543.     WinBox(TopRow,LeftColumn,BottomRow,RightColumn,0,4, ;
  544.                if(BottomRow==maxrow()-1,.f.,.t.) ;
  545.             )
  546.  
  547.     @ TopRow, LeftColumn+1 say " " + eval( x:UserSlot[1] ) + ;
  548.                                      "  < Window  " + ;
  549.                                      str(select(),1,0)+" > " ;
  550.                                    color x:InverseColor
  551.     if x:Userslot[3] # NIL
  552.       eval( x:UserSlot[3] )
  553.     endif
  554.  
  555.  
  556. Return( NIL )
  557.  
  558.  
  559. //─────────────────┐
  560. // Resize window   │
  561. //─────────────────┘
  562.  
  563. #define R_TOP            1
  564. #define R_TOPLEFT        2
  565. #define R_TOPRIGHT       3
  566. #define R_BOTTOMLEFT     4
  567. #define R_BOTTOMRIGHT    5
  568.  
  569. #define EXT_SHIFT        ( keybd_Stat(0) == 1 .or. keybd_Stat(1) == 1 )
  570.  
  571. STATIC Func ResizeWindow( x )
  572.  
  573.     Local CurrentScreen := Savescreen(02,00,maxrow(),maxcol()), ;
  574.           line1         := savescreen(01,00,01,maxcol()), ;
  575.           TopRow        := x:TopRow -4, ;
  576.           LeftColumn    := x:LeftColumn -1, ;
  577.           BottomRow     := x:BottomRow +1, ;
  578.           RightColumn   := x:RightColumn +1, ;
  579.           OriginalColor := Setcolor(), ;
  580.           ResizeColor   := x:InverseColor , ;
  581.           nKey          := 0, ;
  582.           drag          := .f. , ;
  583.           holdT         := -1, ;
  584.           holdL         := -1, ;
  585.           holdB         := -1, ;
  586.           holdR         := -1, ;
  587.           holdButton    := 0 , ;
  588.           Mouse         := MouseSys(), ;
  589.           row, ;
  590.           col, ;
  591.           drag_who , ;
  592.           xwidth, ;
  593.           xheight, ;
  594.           xOffset
  595.  
  596.  
  597.     row    := Mouse:Row
  598.     col    := Mouse:Column
  599.  
  600.     Setcolor( ResizeColor )
  601.     @1,0
  602.     NccMesg( ;
  603.          ' Move:  '+chr(26)+ space(7) + ;
  604.          'Resize:  Shift '+chr(26)+ space(7) + ;
  605.          'Done:  ─┘', ;
  606.          1, ;
  607.          'Center' ;
  608.         )
  609.  
  610.     WHILE .t.
  611.  
  612.       if ! (                              ;
  613.              holdT == TopRow        .and. ;
  614.              holdL == LeftColumn    .and. ;
  615.              holdB == BottomRow     .and. ;
  616.              holdR == RightColumn         ;
  617.            )
  618.  
  619.         Mouse:Hide()
  620.         Restscreen(02,00,maxrow(),maxcol(),CurrentScreen)
  621.         @ TopRow, LeftColumn, BottomRow, RightColumn  Box '┌─┐│┘─└│'
  622.         Mouse:Show()
  623.  
  624.         holdT :=  TopRow
  625.         holdL :=  LeftColumn
  626.         holdB :=  BottomRow
  627.         holdR :=  RightColumn
  628.  
  629.       endif
  630.  
  631.       xheight := BottomRow - TopRow
  632.       xwidth  := RightColumn - LeftColumn
  633.  
  634.       if Mouse:Button == 0
  635.         if drag
  636.           exit
  637.         endif
  638.         Mouse:MouseRead()
  639.         row := Mouse:Row
  640.         col := Mouse:Column
  641.       endif
  642.  
  643.       if Mouse:Ascii # 0
  644.         nKey := Mouse:Ascii
  645.         Do Case
  646.           Case nKey == K_ESC .or. nKey == K_RETURN
  647.             exit
  648.  
  649.           Case nKey == K_UP .and. ! EXT_SHIFT
  650.              if TopRow > 2
  651.                TopRow--
  652.                BottomRow--
  653.              endif
  654.  
  655.           Case nKey == K_DOWN .and. ! EXT_SHIFT
  656.              if BottomRow < maxrow() -1
  657.                TopRow++
  658.                BottomRow++
  659.              endif
  660.  
  661.           Case nKey == K_LEFT .and. ! EXT_SHIFT
  662.              if LeftColumn > 0
  663.                LeftColumn--
  664.                RightColumn--
  665.              endif
  666.  
  667.           Case nKey == K_RIGHT .and. ! EXT_SHIFT
  668.              if RightColumn < maxcol()
  669.                LeftColumn++
  670.                RightColumn++
  671.              endif
  672.  
  673.             Case nKey == K_UP .or. ( EXT_SHIFT .and. nKey == 56 )
  674.                if BottomRow - 6 > TopRow
  675.                  BottomRow--
  676.                endif
  677.  
  678.             Case nKey == K_DOWN .or. ( EXT_SHIFT .and. nKey == 50 )
  679.                if BottomRow < maxrow() -1
  680.                  BottomRow++
  681.                endif
  682.  
  683.             Case nKey == K_LEFT .or. ( EXT_SHIFT .and. nKey == 52 )
  684.                if RightColumn > LeftColumn + 21
  685.                  RightColumn--
  686.                endif
  687.  
  688.             Case nKey == K_RIGHT .or. ( EXT_SHIFT .and. nKey == 54 )
  689.                if RightColumn < maxcol()
  690.                  RightColumn++
  691.                endif
  692.  
  693.         EndCase
  694.  
  695.       elseif Mouse:Button # LEFT_BUTTON
  696.         nKey := K_RETURN
  697.         exit
  698.  
  699.       elseif Mouse:Button == LEFT_BUTTON
  700.         if drag
  701.           Mouse:Update()
  702.           row := Mouse:Row
  703.           col := Mouse:Column
  704.           Do Case
  705.             Case drag_who == R_TOPLEFT
  706.               if row <= BottomRow - 6 .and. col <= RightColumn - 30 .and. ;
  707.                  row > 1
  708.                 TopRow := max(2,row)
  709.                 LeftColumn := col
  710.               endif
  711.  
  712.             Case drag_who == R_TOPRIGHT
  713.               if row <= BottomRow - 6 .and. col >= LeftColumn + 30 .and. ;
  714.                 row > 1
  715.                 TopRow := max(2,row)
  716.                 RightColumn := col
  717.               endif
  718.  
  719.             Case drag_who == R_BOTTOMLEFT
  720.               if row >= TopRow + 6 .and. col <= RightColumn - 30 .and. ;
  721.                  row < maxrow()
  722.                 BottomRow   := min( row, maxrow()-1 )
  723.                 LeftColumn  := col
  724.               endif
  725.  
  726.             Case drag_who == R_BOTTOMRIGHT
  727.               if row >= TopRow + 6 .and. col >= LeftColumn + 30 .and. ;
  728.                  row < maxrow()
  729.                 BottomRow   := min( row, maxrow()-1 )
  730.                 RightColumn := col
  731.               endif
  732.  
  733.             Case drag_who == R_TOP
  734.               if row <= Maxrow()-1 - xHeight .and. col - xOffset >= 0 .and. ;
  735.                  col - xOffset + xWidth <= maxcol() .and. row > 1
  736.                 TopRow      := row
  737.                 BottomRow   := row + xHeight
  738.                 LeftColumn  := col - xOffset
  739.                 RightColumn := LeftColumn + xWidth
  740.               endif
  741.  
  742.           EndCase
  743.  
  744.         else
  745.           drag := .t.
  746.           if holdButton == 0
  747.             @1,0
  748.             holdButton := LEFT_BUTTON
  749.             if row == TopRow .and. Col # LeftColumn .and. Col # RightColumn
  750.               NccMesg( ;
  751.                    ' Move:  '+chr(26)+ space(7) + ;
  752.                    'Done:  Release Mouse Button', ;
  753.                    1, ;
  754.                    'Center' ;
  755.                   )
  756.             else
  757.               NccMesg( ;
  758.                    ' Resize:  '+chr(26)+ space(7) + ;
  759.                    'Done:  Release Mouse Button', ;
  760.                    1, ;
  761.                    'Center' ;
  762.                   )
  763.             endif
  764.             Mouse:Show()
  765.           endif
  766.           Do Case
  767.             Case row == TopRow .and. col == LeftColumn
  768.               drag_who := R_TOPLEFT
  769.  
  770.             Case row == TopRow .and. col == RightColumn
  771.               drag_who := R_TOPRIGHT
  772.  
  773.             Case row == BottomRow .and. col == LeftColumn
  774.               drag_who := R_BOTTOMLEFT
  775.  
  776.             Case row == BottomRow .and. col == RightColumn
  777.               drag_who := R_BOTTOMRIGHT
  778.  
  779.             Case row == TopRow .and. col >= LeftColumn .and. col <= RightColumn
  780.               drag_who := R_TOP
  781.               xOffset  := Col - Leftcolumn
  782.  
  783.             Otherwise
  784.               exit
  785.  
  786.           endcase
  787.         endif
  788.       elseif Mouse:Button == BOTH_BUTTONS
  789.          exit
  790.       elseif Mouse:Button == RIGHT_BUTTON
  791.          exit
  792.       else
  793.         exit
  794.       endif
  795.  
  796.     ENDDO
  797.  
  798.     Mouse:Hide()
  799.  
  800.     nKey           := Current_Window()
  801.     x:TopRow       := TopRow+4
  802.     x:LeftColumn   := LeftColumn+1
  803.     x:BottomRow    := BottomRow-1
  804.     x:RightColumn  := RightColumn-1
  805.  
  806.     WinTop(nKey, TopRow)
  807.     WinLeft(nKey, LeftColumn)
  808.     WinBottom(nKey, BottomRow)
  809.     WinRight(nKey, RightColumn)
  810.  
  811.     Setcolor( OriginalColor )
  812.     restscreen(01,00,01,maxcol(),line1)
  813.  
  814. Return( NIL )
  815.  
  816.